package com.jas.storage;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import junit.framework.Assert;

import org.junit.Test;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.jas.common.DeadlineEvent;
import com.jas.common.Event;
import com.jas.common.EventDateException;
import com.jas.common.FloatingEvent;
import com.jas.common.TimedEvent;

public class StorageTest {

	//@author a0118677r
	@Test
	public static void testStorage() throws EventDateException{
		testStoreEventList();
	}
	
	//@author a0118677r
	private static void testStoreEventList() throws EventDateException{
		List<Event> testList = new ArrayList<Event>();
		
		testList.add(new FloatingEvent("event 1"));
		DeadlineEvent de = new DeadlineEvent("event 2", Calendar.getInstance());
		de.setCompleted(true);
		testList.add(de);
		try {
			testList.add(new TimedEvent("event 3", Calendar.getInstance(), Calendar.getInstance()));
		} catch (EventDateException e1) {
			fail("Failed due to an EventDateException");
		}

		try {
			StorageAPI.storeEventList(testList);
		} catch (StorageException e) {
			fail("Could not save file");
		}
	}
}
